package cn.org.zx.db.dbconnection.impl;

import java.sql.*;

import cn.org.zx.db.dbexception.DBErrorException;

public class MysqlDBConnection extends DefaultDBConnection
{
    public MysqlDBConnection()
    {
    }
	@Override
    public void openbyJDBC(String url, String username, String password)
    throws DBErrorException
	{
	    try    
	    { 
	    	Class.forName("com.mysql.jdbc.Driver");
	        connection = DriverManager.getConnection(url, username, password);
	        stmt = connection.createStatement();
	    }
	    catch(ClassNotFoundException e)
	    {
	        e.printStackTrace();
	        throw new DBErrorException("JDBC驱动[com.mysql.jdbc.Driver]未发现");
	    }
	    catch(SQLException e)
	    {
	        e.printStackTrace();
	        throw new DBErrorException("JDBC连接失败，[url:" + url + ",user:" + username + "，password:" + password);
	    }
	}
	
    //
    public static void main(String args[])
    {
        
    }
}
